package com.sun.rabbitMQ.WorkQueues;

import com.rabbitmq.client.Channel;
import com.sun.rabbitMQ.utils.FactoryUtils;

import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;

public class Producer {
    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = FactoryUtils.getChannel();
        channel.queueDeclare(FactoryUtils.QUEUE_NAME,false,false,false,null);

        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String message = scanner.next();
            channel.basicPublish("",FactoryUtils.QUEUE_NAME,null,message.getBytes());
            System.out.println("消息发送成功了！！");
        }
    }
}
